home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / zindent7.zip / ZINDENT7.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-03-30  |  12.0 KB  |  407 lines

  1. (*<<<>>>*)
  2.  
  3.  
  4. (*******************************************************************)
  5. (**)                                                             (**)
  6. (**)                PROGRAM     ZINDENT ;                        (**)
  7. (**)                                                             (**)
  8. (*******************************************************************)
  9.  
  10. CONST
  11.  
  12. SysTitle    =
  13. 'zINDENT.PAS, v. 7.D, Indent for dBASE / Turbo Pascal Source Files';
  14.  
  15. SysVersion1 = 'Command via : Line / File / User';
  16.  
  17. SysVersion2 = 'MSDOS version 0300pm, mon, 30.Mar.87, Glen Ellis';
  18.  
  19. SysCredit   = 'Apple/CPM  and  MSDOS  tested.            ';
  20.  
  21. SysPgmName  = 'ZINDLIST.DAT';  (* file containing filename list *)
  22.  
  23. SysCpuSpeed = 2 ; (* author's writing/developmental system is 2 MHz ! *)
  24.  
  25. (* parameters FOR Compiler *)
  26. {$C+}
  27. {$U+} (* $U+ User Interrupt benchmarks almost same as $U- *)
  28. {$F4}
  29.  
  30. (* parameters FOR LISTT.PAS, Borland's advanced Lister program *)
  31. {.U+}
  32. {.N-}
  33. {.P-}
  34. {.PO0}
  35.  
  36.  
  37. (*####################################################################*)
  38.  
  39. (*$I c:zinVAR.INC*) (* for core program *)
  40. (*$I C:zinSTR.INC*) (* required string utilties *)
  41. (*$I C:zinSCR.INC*) (* screen display procedures *)
  42. (*$I C:zinDOC.INC*) (* system documentation / readme.inc *)
  43. (*   C:ZReadme.INC*) (* not Pascal include file *)
  44. (*$I C:zinUTL.INC*) (* miscelaneous procedures *)
  45. (*$I C:zinDSK.INC*) (* disk file procedures *)
  46. (*$I C:zinKEYDB.INC*)  (* keyword dBASE *)
  47. (*$I C:zinKEYTP.INC*)  (* keyword Pascal *)
  48.  
  49.  
  50. (********************************************************************)
  51.  
  52.  
  53. BEGIN (*  MAIN  *)
  54.  
  55.    (*=======> INIT <=======*)
  56.  
  57.    (* programmer's options *)
  58.  
  59.    SysDisplay    := true  ;    (* always true   *)
  60.  
  61.    SysUserTrace  := true  ;    (* normal : display program path *)
  62.  
  63.    SysPgmTrace   := false ;    (* audit developmental path *)
  64.  
  65.    SysSpcTrace   := false ;    (* special, temporary *)
  66.  
  67.    (* name/function of procedure *) (* located in this file *)
  68.    (*                            *) (*                      *)
  69.    pSayHeader; (* Display header *) (* SysScr.inc           *)
  70.  
  71.    IF not SysPgmTrace then pDelay2;
  72.  
  73.    (*=======> FETCH <=======*)
  74.  
  75.    (* initz *)
  76.    SysPgmMod     := '  '  ;
  77.  
  78.    (* fetch command line from either paramstring or paramfile
  79.    (* set defaults for operational vars :
  80.    (*   Filename, Indent, Comment, LineCount, Vertiate
  81.    *)
  82.  
  83.    (* set mode flags true *)
  84.    (* ZinLine.Inc will re-assign *)
  85.    SysCmdLine := true ; (* enable Command Line Parse *)
  86.    SysCmdFile := false; (* file names via text file  *)
  87.    SysCmdUser := false; (* direct keyboard entry     *)
  88.  
  89.    (* parameter flags : if satisfied, then lower flag *)
  90.    SysCmdUserFile := false ;  (*  filename fetch *)
  91.    SysCmdUserParm := false ;  (*  parameter fetch *)
  92.  
  93.    (*=======> FETCH LINE ENTRY *)
  94.  
  95.    IF SysCmdLine then
  96.    begin
  97.  
  98.       IF SysPgmTrace then
  99.       begin
  100.          writeln; writeln;
  101.          writeln('--> SysCmdLINE');
  102.          pDelay1;
  103.       end;
  104.  
  105.       (*$I c:zinLINE.INC*) (*:::*)
  106.  
  107.       (* if user entered no command line, or requested Docs, then *)
  108.       (* pause while he reads header *)
  109.       If (SysInFileName = '?') then
  110.       begin
  111.          writeln; writeln;
  112.          writeln('User Entry / Documentation has been enabled . . . .');
  113.          pKeyPressed;
  114.       end;
  115.  
  116.    end;
  117.  
  118.    (*=======> FETCH FILE ENTRY *)
  119.  
  120.    IF SysCmdFile then
  121.    begin
  122.       IF SysPgmTrace then
  123.       begin
  124.          writeln('---> SysCmdFILE');
  125.          pDelay1;
  126.       end;
  127.       SysInFileName := SysPgmName;  (* read data file name *)
  128.       (*$I c:zinFILE.INC*) (*:::*)
  129.    end;
  130.  
  131.    (*=======> FETCH USER ENTRY *)
  132.  
  133.    IF ( (SysCmdUser) and (SysCmdUserFile) )
  134.    or
  135.       ( (SysCmdUser) and (SysCmdUserparm) )
  136.    then
  137.    begin
  138.       IF SysPgmTrace then
  139.       begin
  140.           writeln('---> SysCmdUSER');
  141.           pDelay1;
  142.       end;
  143.       (*$I c:zinUSER.INC*) (*:::*)
  144.    end;
  145.  
  146.    (*=======> CORE CONTROLLER <=======*)
  147.  
  148.    (* if filename and parameters installed *)
  149.    IF (SysCmdLine) or (SysCmdFile) or (SysCmdUser)
  150.       then SysEnableCORE := true
  151.    ELSE SysEnableCORE := false;
  152.  
  153.    IF SysUserTrace  then (* display list of file names *)
  154.    begin
  155.       writeln('SysUserTrace enabled');
  156.       pSayFileList; (*::: SysUtl.INC *)
  157.    end;
  158.  
  159.    IF SysPgmTrace then
  160.    begin
  161.       pSaySysVar;  (* big VAR display prior to CORE *)
  162.    end;
  163.  
  164.    (*=======> CORE <=======*)
  165.  
  166.    IF SysEnableCore then
  167.    begin
  168.  
  169.       IF SysPgmTrace then
  170.       begin
  171.          writeln('--- Enable Core ---');
  172.          pDelay1;
  173.       end;
  174.  
  175.       (* init : cmdline/cmdfile/cmduser *)
  176.       IF (SysInSourceMax = 0)
  177.          then SysInSourceMax := 1;
  178.  
  179.       (*=========================================*)
  180.       FOR SysInSourceCnt := 1 to SysInSourceMax do
  181.       begin  (* Count Through InSource Array of FileNames *)
  182.  
  183.          (* fetch new filename *)
  184.          (* parse for .typ *)
  185.          (* start file *)
  186.          (* read loop *)
  187.  
  188.          (* load the carrier memvar *)
  189.          SysInFileName := SysInSource[SysInSourceCnt];
  190.  
  191.          writeln('FileName : ', SysInFileName,' :');
  192.          pDelay1;
  193.  
  194.          (*=======> Parse file.typ for mode : OL, DB, TP *)
  195.  
  196.          (*:::*)
  197.          (* can be preset (forced) by user in SysUser.Inc. *)
  198.          (* default entry is '  '. *)
  199.  
  200.          if (SysPgmMod = '  ') then
  201.          begin
  202.  
  203.             pSysParse( SysInFileName, SysPgmMod, SPMSL, SPMSR );
  204.             (*::: SysDsk.INC *)
  205.  
  206.          (* IF SysPgmTrace then *)
  207.          (* begin               *)
  208.                writeln('Results of FileName Parse :',SysPgmMod,':');
  209.                pDelay1;
  210.          (* end; *)
  211.  
  212.          end;
  213.  
  214.          (*=======> Start Files *)
  215.  
  216.          (* create  three file.type vars for  .BAK, .(source), .$$$
  217.          (*         Open, Reset, Rewrite files *)
  218.          IF SysPgmTrace then
  219.          begin
  220.             writeln;
  221.             writeln('--- Start Files ---');
  222.             pDelay1;
  223.          end;
  224.  
  225.          SysIOcheck := true ; (* any one dead file will skip loop one time ! *)
  226.  
  227.          pSysStartFiles(SysIOcheck);  (*::: SysUtl.INC *)
  228.  
  229.          (*---------------*)
  230.          IF SysIOcheck then
  231.          begin
  232.  
  233.             IF SysUserTrace then
  234.             begin
  235.                writeln;
  236.                writeln('--- Start Read Loop --- ',SysInFileName);
  237.                pDelay1;
  238.             end;
  239.  
  240.             (* prep for linecnt during WHILE loop *)
  241.             SysLineNum := 0;
  242.  
  243.             (* operational var set to zero *)
  244.             pSysLvlInit;  (*::: SysUtl.INC *)
  245.  
  246.             (*=======> Scan Through File *)
  247.  
  248.             WHILE not (eof(SysInFile))
  249.             do
  250.             begin
  251.  
  252.                (* read text line from input file *)
  253.                readln(SysInFile,SysInLine);
  254.  
  255.                (* assign output string to value read in *)
  256.                SysOutLine := SysInLine;
  257.  
  258.                (* writing parms are long for indentifiability *)
  259.                (* procedure parms are small so line will be < 127 *)
  260.  
  261.                (* update short vars *)
  262.                pSysVarShortUPdt; (*::: SysUtl.INC *)
  263.  
  264.                (*===================================================
  265.                (*
  266.                (* current KeyWord module application flow:
  267.                (*
  268.                (* identify   KEYWORD,    and adjust indent
  269.                (* SysUserTrace start/stop of structures
  270.                (* toggle sysmarkwrite
  271.                (* OutSTR = exit line
  272.                (* indentPOS = current left margin position
  273.                (* indentNUM = actual indent group length
  274.                (* lineMAX   = max length of text line = 79
  275.                (* markWRITE = enable comments write to disk
  276.                (**)
  277.  
  278.                (*
  279.                (*   Indent for dBASE-II
  280.                (**)
  281.  
  282.                IF SysPgmMod = 'DB'
  283.                then
  284.                pKEYDB( SOLL, SIP, SIN, SLM, SMW, SLI, SLC, SLW);
  285.                (*::: KeyDB.INC*)
  286.  
  287.                (*
  288.                (*   Indent for Turbo Pascal
  289.                (**)
  290.  
  291.                IF SysPgmMod = 'TP'
  292.                then
  293.                pKEYTP( SOLL, SIP, SIN, SLM, SMW, SEB, SLB );
  294.                (*::: KeyTP.INC*)
  295.  
  296.                (* next application
  297.                (*   find string in file system , write to single file
  298.                (*   application in Treefile
  299.                (*  pFIND( RefStr, FndStr, fndcnt );*)
  300.  
  301.                (* update long vars *)
  302.                pSysVarLongUpdt; (*::: SysUtl.INC *)
  303.  
  304.                (* line count prefixer, handled in STRING.INC *)
  305.                (* inc, concates number + string *)
  306.                IF SysLineCnt
  307.                   then pLINECOUNT(SysOutLine, SysLineNum);
  308.                (*::: string.inc *)
  309.  
  310.                (* WRITE the file data *)
  311.                IF (SysMarkWrite)
  312.                   then writeLn(SysOutFile,SysOutLine);
  313.  
  314.                (* DISPLAY data string *)
  315.                IF (SysDisplay) and (SysMarkWrite)
  316.                   then writeln(SysOutLine);
  317.  
  318.             end; (* WHILE not (eof(SysInFile)) do *)
  319.             (*------------------------------------*)
  320.  
  321.             (* KEYWORD.INC application routine *)
  322.             (* appends level(stack) numbers to tail of OutFile *)
  323.             (* level/error audit trail *)
  324.             (*    pSysLvlWrite;    (*::: SysUtl.INC *)
  325.             (**)
  326.  
  327.             (*---------------------------------*)
  328.             close(SysInFile);   (*  InFile.CMD *)
  329.             close(SysOutFile);  (* OutFile.TXT *)
  330.  
  331.  
  332.             (* LineCnt would produce a un-runnable command file *)
  333.             (* do not allow generated file to become file.CMD *)
  334.             (* else, OK to rename files *)
  335.             IF (not SysLineCnt)
  336.             then
  337.             begin
  338.                (* if SysPgmMod not "  " then type is recognized *)
  339.                (* mode must be valid, else leave OutFile as .$$$ *)
  340.                pSysReName(SysIOcheck); (*::: SysUtl.INC *)
  341.             end;
  342.  
  343.             (* KEYWORD application routine *)
  344.             (* Sends level(stack) numbers to video. *)
  345.             (* Has been used nicely to attach extra line on output file. *)
  346.             (* Works with KEYword.INC modules *)
  347.  
  348.             IF SysDisplay then
  349.             begin
  350.  
  351.             (* a useful feature on an earlier version
  352.             (* was to write this line on the tail of the OutFile
  353.             (* producing a audit of the possible structural errors.
  354.             (* See notes in ZinUtl.inc.
  355.             (* *)
  356.  
  357.                IF SysPgmMod = 'DB' then
  358.                begin
  359.                   writeln('----------------------------');
  360.                   writeln('------- dBASE Levels -------');
  361.                   writeln(SPMSL, ':I:',SLI,'  :C:',SLC,'  :W:',SLW, SPMSR);
  362.                   writeln('----------------------------');
  363.                   pDelay1;
  364.                end;
  365.  
  366.                (* author traces only the Begin/End counter *)
  367.                (* memvar SLB is the Begin/End counter *)
  368.                IF SysPgmMod = 'TP' then
  369.                begin
  370.                   writeln('----------------------------------');
  371.                   writeln(SPMSL,'Turbo Pascal : B : ',SLB,SPMSR);
  372.                   writeln('----------------------------------');
  373.                   pDelay1;
  374.                end;
  375.  
  376.             end; (* if sysdisplay *)
  377.  
  378.             IF SysPgmTrace
  379.                then writeln('--- End Read Loop ---',SysInFileName);
  380.  
  381.          end; (* if SysIOcheck true *)
  382.  
  383.          IF not SysIOcheck
  384.             then writeln('SysIOcheck  = ',SysIOcheck);
  385.  
  386.          (*---------------------------*)
  387.  
  388.       end; (* FOR SysInSourceCnt := 1 to SysInSourceMAX *)
  389.       (*------------------------------------------------*)
  390.       (* bottom of count through insource array *)
  391.  
  392.    end; (* IF SysEnableCore *)
  393.  
  394.  
  395.    (*=======> NOT CORE <=======*)
  396.  
  397.    (* IF no parameters entered, *)
  398.    (* then default is documentation / InStructions *)
  399.  
  400.    IF not SysEnableCore
  401.       then pSaySysDoc; (*::: SysDOC.INC *)
  402.  
  403.  
  404.  
  405. END.  (*  MAIN  *)
  406.  
  407. (*******************************************************************)
  408. (*<<<>>>*)